Skip to content

chore: migrate docs examples off spl-token#1476

Closed
h4rkl wants to merge 1 commit into
mainfrom
chore/migrate-spl-token-to-kit
Closed

chore: migrate docs examples off spl-token#1476
h4rkl wants to merge 1 commit into
mainfrom
chore/migrate-spl-token-to-kit

Conversation

@h4rkl

@h4rkl h4rkl commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the direct @solana/spl-token dependency from @workspace/docs-examples and prune its lockfile graph.
  • Bump the package's @solana/kit specifier to ^6.9.0.
  • Move the package example files that imported @solana/spl-token onto Kit / @solana-program/token APIs so the package remains typecheckable and tested.

Docs content was intentionally left unchanged per the package-only scope.

Why

@solana/spl-token belongs to the legacy web3.js client path. The current token-2022 repo lists a Kit-generated JS client separately from the "JS-legacy client (using @solana/web3.js)" path: https://github.com/solana-program/token-2022#managing-clients

The dependency also pulled in bigint-buffer@1.1.5 through @solana/buffer-layout-utils. GitHub Advisory GHSA-3gc7-fjrx-p6mg / CVE-2025-3194 marks bigint-buffer <= 1.1.5 as high severity with no patched version, so removing the SPL Token dependency graph is the clean mitigation: GHSA-3gc7-fjrx-p6mg

Note: npm does not currently expose a deprecated metadata field for @solana/spl-token; this PR treats the deprecation as the legacy client path and the ecosystem move to Kit for maintained JS token clients.

Validation

  • pnpm install --frozen-lockfile --ignore-scripts
  • pnpm --filter @workspace/docs-examples lint
  • pnpm --filter @workspace/docs-examples test (61 files / 61 tests passed)
  • pnpm audit --prod --json still exits non-zero for unrelated workspace advisories, but parsed output has no @solana/spl-token or bigint-buffer findings and reports 0 critical vulnerabilities.

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

6 Skipped Deployments
Project Deployment Actions Updated (UTC)
solana-com Skipped Skipped May 27, 2026 3:53am
solana-com-accelerate Skipped Skipped May 27, 2026 3:53am
solana-com-breakpoint-2 Skipped Skipped May 27, 2026 3:53am
solana-com-docs Skipped Skipped May 27, 2026 3:53am
solana-com-media Skipped Skipped May 27, 2026 3:53am
templates Skipped Skipped May 27, 2026 3:53am

Request Review

@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes @solana/spl-token from the @workspace/docs-examples package, replacing its usage across seven example files with @solana-program/token, @solana-program/token-2022, and @solana/kit plugin APIs. The primary motivation is eliminating the transitive bigint-buffer@1.1.5 CVE-2025-3194 vulnerability with no available patch.

  • Token lookup examples (get-token-account, get-token-mint, get-all-token-accounts) are cleanly migrated to the Kit RPC + program-client equivalents.
  • The fee-sponsorship files (legacy.ts and legacy-helper.ts) are both rewritten to use Kit's createClient plugin chain, but end up with identical content — the original contrast between raw-instruction construction and high-level helpers is lost.
  • The pay-fees-with-any-token example is functionally migrated but drops the final balance verification for all three parties, which was the concrete proof-of-concept step.

Confidence Score: 3/5

The token-lookup files and package.json changes are safe; the fee-sponsorship pair needs attention before merging.

The three token-read examples and the dependency removal are clean. The fee-sponsorship migration is the problem area: legacy.ts and legacy-helper.ts now have byte-for-byte identical content, erasing the deliberate low-level vs. helper contrast the pair was built to show. The pay-fees-with-any-token file also drops its final balance check, reducing its usefulness as a verifiable example.

packages/docs-examples/cookbook/transactions/fee-sponsorship/legacy.ts and legacy-helper.ts need to be differentiated; packages/docs-examples/cookbook/transactions/pay-fees-with-any-token/legacy.ts could benefit from restored balance verification.

Important Files Changed

Filename Overview
packages/docs-examples/cookbook/transactions/fee-sponsorship/legacy.ts Migrated to Kit APIs, but the resulting file is byte-for-byte identical to legacy-helper.ts, erasing the intentional low-level vs. helper distinction between the two example files.
packages/docs-examples/cookbook/transactions/fee-sponsorship/legacy-helper.ts Successfully migrated from spl-token helpers to @solana/kit-plugin-rpc / @solana-program/token APIs; logic is correct and the fee-sponsorship flow is preserved.
packages/docs-examples/cookbook/transactions/pay-fees-with-any-token/legacy.ts Migrated to Kit APIs; reimbursement flow is structurally correct, but the final balance verification for feePayer/sender/recipient was dropped, reducing the example's educational completeness.
packages/docs-examples/cookbook/tokens/get-all-token-accounts/all-legacy.ts Clean migration from spl-token + web3.js to @solana-program/token + @solana/kit; API semantics preserved with jsonParsed encoding.
packages/docs-examples/cookbook/tokens/get-token-account/legacy.ts Clean swap of getAccount (spl-token) for fetchToken (@solana-program/token-2022) with equivalent commitment semantics.
packages/docs-examples/cookbook/tokens/get-token-mint/legacy.ts Clean replacement of getMint with fetchMint; supply serialization simplified since Kit returns proper typed data.
packages/docs-examples/package.json Removes @solana/spl-token dependency and bumps @solana/kit to ^6.9.0; lockfile updated accordingly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[fee-sponsorship example] --> B[createClient]
    B --> C[payer - feePayer signer]
    B --> D[solanaRpc plugin]
    B --> E[rpcAirdrop - fund feePayer]
    B --> F[tokenProgram plugin]

    F --> G[createMint instruction]
    F --> H[mintToATA instruction]
    G & H --> I[sendTransaction - setup]

    F --> J[transferToATA instruction]
    J --> K[sendTransaction - transfer]

    K --> L[findAssociatedTokenPda]
    L --> M[fetchToken - verify balances]
Loading

Reviews (1): Last reviewed commit: "chore: migrate docs examples off spl-tok..." | Re-trigger Greptile

Comment on lines 1 to 5
// #region sponsor
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { rpcAirdrop, solanaRpc } from "@solana/kit-plugin-rpc";
import { airdropPayer, payer } from "@solana/kit-plugin-signer";
import {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Identical content as legacy-helper.ts

After this migration, legacy.ts and legacy-helper.ts are byte-for-byte identical. Originally legacy.ts showed the low-level raw-instruction path (createInitializeMintInstruction, manual Transaction assembly) while legacy-helper.ts showed the high-level helper-function path (createMint, createAssociatedTokenAccount, etc.) — a deliberate side-by-side contrast. Now any reader or doc page that cites both files will see the same code twice, erasing the distinction the pair was designed to illustrate.

Comment on lines +71 to 77
]);
console.log("Transaction Signature:", transfer.context.signature);
console.log(
"Fee Payer balance:",
Number(feePayerTokenAccount.amount) / 100,
"tokens",
);
console.log(
"Sender balance:",
Number(senderTokenAccount.amount) / 100,
"tokens",
);
console.log(
"Recipient balance:",
Number(recipientTokenAccount.amount) / 100,
"tokens",
"Successfully transferred 0.5 tokens to recipient + 0.5 to fee payer",
);

// #endregion pay-fees

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Final balance verification removed

The original example fetched and logged the final token balances for all three parties (feePayer, sender, and recipient), which concretely proved that the token-reimbursement flow worked. The new version omits those checks entirely, so the example no longer confirms that the fee payer's ATA was actually credited — the stated goal of the "pay fees with any token" pattern. Someone reading the code as documentation loses the concrete verification step.

@h4rkl h4rkl closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant